package com.pucheng.bracelet.app.database.repository

import androidx.annotation.WorkerThread
import androidx.lifecycle.LiveData
import com.pucheng.bracelet.app.App
import com.pucheng.bracelet.app.database.dao.AllDataHRDao
import com.pucheng.bracelet.data.bean.AllHertRateBean
import kotlinx.coroutines.flow.Flow

/**
 * 数据库集合
 */
class AllDataHRRepository() {

    //步数
    private val hertRate: AllDataHRDao = App.instance.database.allHRDao()

    //查询所有数据
    val allDataTo7DayToHertrate: Flow<List<AllHertRateBean>> = hertRate.get7Days()

    //查询所有数据
    val allDataToHertrate: Flow<List<AllHertRateBean>> = hertRate.getAll()

    //    //查询指定日期的数据
    fun getHertratesInfoToDate(date: String) :LiveData<AllHertRateBean> = hertRate.getDataToDate(date)

    // 插入数据
    @Suppress("RedundantSuspendModifier")
    @WorkerThread
    suspend fun insertHertrateToList(list: List<AllHertRateBean>) {
        hertRate.insertToList(list)
    }


}